import os
from yaml import safe_load

conf = os.path.join(os.getcwd(), "conf", "config.yaml")


class Config:
    def __init__(self):
        with open(conf, 'r', encoding='utf-8') as f:
            self.config = safe_load(f)

    def host(self):
        host = self.config['service']['host']
        return host

    def port(self):
        port = self.config['service']['port']
        return port

    def access(self):
        name = self.config['service']['log']['request']
        return name

    def error(self):
        name = self.config['service']['log']['error']
        return name

    def log_level(self):
        level = self.config['service']['log']['level']
        return level

    def log_dir(self):
        d = self.config['service']['log']['dir']
        return d

    def wechat_webhooks(self):
        keys = self.config['service']['wechat']['key']
        return keys

    def dingtalk_webhooks(self):
        webhook = self.config['service']['dingtalk']
        print(webhook)
        return webhook


config = Config()
